package wechat

// Country 微信支付地区常量
type Country int

// 微信支付地区常量
const (
	China         Country = 1 // 中国国内
	ChinaRecovery Country = 2 // 中国国内（ 容灾方案 ）
	SoutheastAsia Country = 3 // 东南亚
	Worldwide     Country = 4 // 其他地方
)

// PayCountryUrl 微信支付地区常量名称
var PayCountryUrl = map[Country]string{
	China:         "https://api.mch.weixin.qq.com/",
	ChinaRecovery: "https://api2.mch.weixin.qq.com/",
	SoutheastAsia: "https://apihk.mch.weixin.qq.com/",
	Worldwide:     "https://apius.mch.weixin.qq.com/",
}

// PayMethodApi 微信支付请求方式
type PayMethodApi string

const (
	// MicroPay 提交付款码支付接口
	MicroPay PayMethodApi = "pay/micropay"
	// UnifiedOrder 统一接口
	UnifiedOrder PayMethodApi = "pay/unifiedorder"
	// OrderQuery 查询订单接口
	OrderQuery PayMethodApi = "pay/orderquery"
	// CloseOrder 关闭订单接口
	CloseOrder PayMethodApi = "pay/closeorder"
	// Refund 申请退款接口
	Refund PayMethodApi = "secapi/pay/refund"
	// RefundQuery 查询退款接口
	RefundQuery PayMethodApi = "pay/refundquery"
	// Reverse 撤销订单接口
	Reverse PayMethodApi = "secapi/pay/reverse"
	// DownloadBill 下载对账单接口
	DownloadBill PayMethodApi = "pay/downloadbill"
	// DownloadFundFlow 下载资金账单接口
	DownloadFundFlow PayMethodApi = "pay/downloadfundflow"
	// Report 交易保障接口
	Report PayMethodApi = "payitil/report"
	// BatchQueryComment 拉取用户评价接口
	BatchQueryComment PayMethodApi = "billcommentsp/batchquerycomment"
	// Transfer 微信企业付款接口
	Transfer PayMethodApi = "mmpaymkttransfers/promotion/transfers"
	// TransferQuery 微信企业付款查询接口
	TransferQuery PayMethodApi = "mmpaymkttransfers/gettransferinfo"
	// SendRedPack 发送红包接口
	SendRedPack PayMethodApi = "mmpaymkttransfers/sendredpack"
	// AppletRed 发送小程序红包接口
	AppletRed PayMethodApi = "mmpaymkttransfers/sendminiprogramhb"
	// RedPackQuery 红包查询接口
	RedPackQuery PayMethodApi = "mmpaymkttransfers/gethbinfo"

	// AuthCodeToOpenId 获取openid接口
	AuthCodeToOpenId PayMethodApi = "tools/authcodetoopenid"
	// EntrustWeb 公众账号纯签约
	EntrustWeb PayMethodApi = "papay/entrustweb"
	// EntrustApp 公众号纯签约
	EntrustApp PayMethodApi = "papay/preentrustweb"
	// EntrustH5 H5纯签约
	EntrustH5 PayMethodApi = "papay/h5entrustweb"
	// Paying 查询签约关系接口
	Paying PayMethodApi = "pay/contractorder"
	// EntrustDelete 解约接口
	EntrustDelete PayMethodApi = "papay/deletecontract"
	// PayingQueryContract 查询签约关系接口
	PayingQueryContract PayMethodApi = "papay/querycontract"
	// EntrustApplyPlay 纯签约申请支付接口
	EntrustApplyPlay PayMethodApi = "pay/pappayapply"
	// ProfitSharing 请求单次分账
	ProfitSharing PayMethodApi = "secapi/pay/profitsharing"
	// MultiProfitSharing 请求多次分账
	MultiProfitSharing PayMethodApi = "secapi/pay/multiprofitsharing"
	// ProfitSharingQuery 查询分账结果
	ProfitSharingQuery PayMethodApi = "pay/profitsharingquery"
	// ProfitSharingAddReceiver 添加分账接收方
	ProfitSharingAddReceiver PayMethodApi = "pay/profitsharingaddreceiver"
	// ProfitSharingRemoveReceiver 删除分账接收方
	ProfitSharingRemoveReceiver PayMethodApi = "pay/profitsharingremovereceiver"
	// ProfitSharingFinish 完结分账
	ProfitSharingFinish PayMethodApi = "secapi/pay/profitsharingfinish"
	// ProfitSharingOrderAmountQuery 查询订单待分账金额
	ProfitSharingOrderAmountQuery PayMethodApi = "pay/profitsharingorderamountquery"
	// ProfitSharingMerchantRatioQuery 查询最大分账比例
	ProfitSharingMerchantRatioQuery PayMethodApi = "pay/profitsharingmerchantratioquery"
	// ProfitSharingReturn 分账退回
	ProfitSharingReturn PayMethodApi = "secapi/pay/profitsharingreturn"
	// ProfitSharingReturnQuery 分账回退结果查询
	ProfitSharingReturnQuery PayMethodApi = "pay/profitsharingreturnquery"
	// PayBank 企业付款到银行卡API
	PayBank PayMethodApi = "mmpaysptrans/pay_bank"
	// QueryBank 查询企业付款到银行卡API
	QueryBank PayMethodApi = "mmpaysptrans/query_bank"
)

// CDATA <![CDATA[TEST]]> 数据
type CDATA struct {
	Value string `xml:",cdata"`
}

// GetFullApiUrl 获取完整api地址
// country: 微信支付地区
func (wechat PayMethodApi) GetFullApiUrl(country Country) string {
	return PayCountryUrl[country] + string(wechat)
}
